// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#include <pollux/expression/vector_function.h>

namespace kumo::pollux::functions::sparksql {
    // Supported types:
    //   - Boolean
    //   - Integer types (tinyint, smallint, integer, bigint)
    //   - Varchar, varbinary
    //   - Real, double
    //   - Decimal
    //   - Date
    //   - Timestamp
    //
    // TODO:
    //   - Row, Array: hash the elements in order
    //   - Map: iterate over map, hashing key then value. Since map ordering is
    //        unspecified, hashing logically equivalent maps may result in
    //        different hash values.

    std::vector<std::shared_ptr<exec::FunctionSignature> > hashSignatures();

    std::vector<std::shared_ptr<exec::FunctionSignature> > hashWithSeedSignatures();

    std::shared_ptr<exec::VectorFunction> makeHash(
        const std::string &name,
        const std::vector<exec::VectorFunctionArg> &inputArgs,
        const core::QueryConfig &config);

    std::shared_ptr<exec::VectorFunction> makeHashWithSeed(
        const std::string &name,
        const std::vector<exec::VectorFunctionArg> &inputArgs,
        const core::QueryConfig &config);

    // Supported types:
    //   - Bools
    //   - Integer types (byte, short, int, long)
    //   - String, Binary
    //   - Float, Double
    //   - Decimal
    //   - Date
    //   - Timestamp
    //   - UnknownType
    //   - Struct
    //   - Array
    //   - Map

    std::vector<std::shared_ptr<exec::FunctionSignature> > xxhash64Signatures();

    std::vector<std::shared_ptr<exec::FunctionSignature> >
    xxhash64WithSeedSignatures();

    std::shared_ptr<exec::VectorFunction> makeXxHash64(
        const std::string &name,
        const std::vector<exec::VectorFunctionArg> &inputArgs,
        const core::QueryConfig &config);

    std::shared_ptr<exec::VectorFunction> makeXxHash64WithSeed(
        const std::string &name,
        const std::vector<exec::VectorFunctionArg> &inputArgs,
        const core::QueryConfig &config);

    exec::VectorFunctionMetadata hashMetadata();
} // namespace kumo::pollux::functions::sparksql
